<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    手机号码: <input type="text" /> <button>发送</button>
    <script>
      let input = document.querySelector("input");
      let button = document.querySelector("button");
      let i = 3;
      let item = null;
      button.addEventListener("click", function () {
        this.disabled = true;
        let item = setInterval(function () {
          if (i == 0) {
            clearInterval(item);
            button.disabled = false;

            button.innerHTML = "发送";
            i = 3;
          } else {
            button.innerHTML = `还剩下${i}秒`;
            i--;
          }
        }, 1000);
      });
    </script>
  </body>
</html>
